/*
package com.huqing.icu.rentplatform.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.huqing.icu.base.IdReq;
import com.huqing.icu.base.PagingDto;
import com.huqing.icu.dto.report.ReportTypeConfigQueryDto;
import com.huqing.icu.enums.DeleteStatusEnum;
import com.huqing.icu.model.report.ReportTypeConfig;
import com.huqing.icu.rentplatform.dao.report.ReportTypeConfigDao;
import com.huqing.icu.rentplatform.inout.in.report.ReportTypeConfigQueryReq;
import com.huqing.icu.rentplatform.inout.in.report.ReportTypeConfigSaveReq;
import com.huqing.icu.rentplatform.mapper.ReportTypeConfigMapper;
import com.huqing.icu.rentplatform.service.ReportTypeConfigService;
import com.huqing.icu.utils.CopyUtils;
import com.huqing.icu.utils.JsonUtils;
import com.huqing.icu.utils.PageUtils;
import com.huqing.icu.utils.ParamValidateUtils;
import jakarta.annotation.Resource;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

*/
/**
 * 举报类型配置实现类
 *
 * @author huqing
 * @date 2024-11-19 20:40
 *//*

@Service
public class ReportTypeConfigServiceImpl extends ServiceImpl<ReportTypeConfigMapper, ReportTypeConfig> implements ReportTypeConfigService {


    @Resource
    private ReportTypeConfigMapper reportTypeConfigMapper;
    @Autowired
    private ReportTypeConfigDao reportTypeConfigDao;

    //创建一个本地缓存，初始化容量为1024，缓存5分钟移除
    private final Cache<String, String> reportTypeConfigCache = Caffeine.newBuilder().initialCapacity(1024).expireAfterAccess(5L, TimeUnit.MINUTES).build();


    */
/**
     * 新增或修改举报类型配置
     *
     * @param saveReq
     * @return
     *//*

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer save(ReportTypeConfigSaveReq saveReq) {
        ReportTypeConfig config = CopyUtils.copy(saveReq, ReportTypeConfig.class);
        reportTypeConfigDao.save(config);

        //查出所有数据，放到本地缓存中
        List<ReportTypeConfig> configList = reportTypeConfigDao.selectByCondition(null);
        String configJson = JsonUtils.obj2String(configList);
        reportTypeConfigCache.put("report_type_config", configJson);
        return 1;
    }

    */
/**
     * 查询举报类型
     *
     * @param queryReq
     * @return
     *//*

    @Override
    public PagingDto<ReportTypeConfig> queryList(ReportTypeConfigQueryReq queryReq) {
        if (queryReq == null) {
            ParamValidateUtils.throwInternalErrorExp("参数不能为空");
        }
        int startIndex = PageUtils.getPageStartIndex(queryReq.getPageIndex(), queryReq.getPageSize());


        //1、查询个数
        ReportTypeConfigQueryDto queryDto = CopyUtils.copy(queryReq, ReportTypeConfigQueryDto.class);
        queryDto.setIsDeleted(0);
        queryDto.setStartIndex(startIndex);
        Integer count = reportTypeConfigDao.getNumByCondition(queryDto);
        if (count == 0) {
            return new PagingDto(Collections.emptyList(), 0, 0);
        }

        //2、查询列表数据
        List<ReportTypeConfig> list = reportTypeConfigDao.selectByCondition(queryDto);
        PagingDto<ReportTypeConfig> pagingDto = new PagingDto<>(list, PageUtils.getTotalPage(count, queryReq.getPageSize()), count);

        return pagingDto;
    }

    */
/**
     * 删除
     *
     * @param idReq
     * @return
     *//*

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Integer delete(IdReq idReq) {
        ParamValidateUtils.validateNotNull(idReq.getIdList(), "主键ID不能为空");

        //1、检查这些举报类型是否存在
        List<ReportTypeConfig> list = lambdaQuery().in(ReportTypeConfig::getId, idReq.getIdList())
                .eq(ReportTypeConfig::getIsDeleted, DeleteStatusEnum.NOT_DELETED.getCode()).list();
        if (CollectionUtils.isEmpty(list)) {
            ParamValidateUtils.throwParamValueIllegalExp("未查到数据，请检查参数");
        }

        //2、如果前端传了n个id,但是数据库只能查到m个，没对上，则需要校验住
        if (idReq.getIdList().size() != list.size()) {
            ParamValidateUtils.throwParamValueIllegalExp("所传参数和数据库的数量对不上");
        }

        //3、删除
        reportTypeConfigMapper.deleteBatchIds(idReq.getIdList());
        return 1;
    }
}
*/
